﻿//this is a plugin sample with vbs

function Plugin_PhotoResize()
{
	var maxwidth=800;
	var elems=XEditor.document.getElementsByTagName("img");
	var i,extname;
	$WebNoteEx.CreateWebNoteTempFolder();
	var tempPath=$WebNoteEx.getTempFolderPath();

	try
	{
		for (i=0;i<elems.length;i++)
		{
			if(parseFloat(elems[i].clientWidth)>maxwidth)
			{
				localfilePath=elems[i].getAttribute("src");
				extname=getFileExt(localfilePath)
				outFilePath=tempPath+"\\"+getAutoName()+"."+extname;
				var g=$WebNoteEx.getImage();
				g.EnableLZW=true;
				g.LoadBitmap(urlFilter(localfilePath));
				g.Resize(maxwidth , maxwidth/g.width*g.height)
		        switch(extname)
		        {
		        	case "jpg":case "jpeg":
		                g.SaveFormat = 1;
		                g.SaveJPEGQuality = 90;
		                break;
		            case "gif": g.SaveFormat = 2;break;
	
		            case "png": g.SaveFormat = 3;break;
	
		            case "tif": case "tiff": g.SaveFormat = 5;break;
		        }
				
				g.SaveBitmap(outFilePath);
				elems[i].outerHTML="<img src=\""+outFilePath+"\">"
				g=null;
		
			}
		}
		PreviewAllLocalIMG();
	}
	catch(e)
	{
		alert(e);
	}
	elems=null;
	

}

